package com.bootssm.dao;

import com.bootssm.entity.Sleep;
import com.bootssm.entity.Sports;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface HealthMapper {
    //作息模块
    //1.查询一个前3条
    @Select("select *from  sleep where userId=#{userId} order by date desc limit 3 ")
    public List<Sleep> findSleep(String userId);
    //    2.增加
    @Insert("insert into sleep set id=#{id},bedtime=#{bedtime},userId=#{userId},date=#{date},score=#{score} ")
    public void  addSleep(Sleep sleep);

//    3.删除
    @Delete("delete from sleep where id=#{id}")
    public  void  deleteSleep(String id);
//    4.评分
    @Select("SELECT AVG(score) FROM sleep where userId=#{userId} ORDER BY date desc LIMIT 7")
    public Integer selectSleepScore(String userId);
    //疾病模块
//    1.查询前三条
    // 2.增加
//    3.删除
    //  4.评分

    //饮食模块
    //1.查询一个前3条
    // 2.增加
    //  3.删除
    // 4.评分

    //运动模块
    //1.查询一个前3条
    @Select("select *from sports where userId=#{userId} ORDER BY date desc limit 3")
    public List<Sports> findSports(String userId);
    //  2.增加
    @Insert("insert into sports set id=#{id},userId=#{userId},date=#{date},exerciseType=#{exerciseType},exerciseTime=#{exerciseTime}")
    public void addSports(Sports sports);
    //  3.删除
    @Delete("delete from sports where id=#{id}")
    public void deleteSports(String id);
    //  4.评分
    @Select("select count(*) from  sports where userId=#{userId}")
      public Integer findSportsScore(String userId);
}
